//
//  XMDUserInforDefault.m
//  XMDefender
//
//  Created by XunFengKJ on 2017/3/20.
//  Copyright © 2017年 XunFengKJ. All rights reserved.
//

#import "BookShareUserInforDefault.h"
static NSString *const HTDYORDERLoginStatus = @"HTDYORDERSysytemloginStatus.data";
static NSString *const HTDYIscanopensecondUser = @"HTDYIscanopensecondUser.data";
static NSString *const HTDYORDERLogintype = @"HTDYORDERlogintype.data";
static NSString *const HTDYORDERAccount = @"HTDYORDERaccount.data";
static NSString *const HTDYORDERUseravatarUrl = @"HTDYORDERshareuseravatarUrl.data";
static NSString *const HTDYORDERaddress = @"HTDYORDERshareaddress.data";
static NSString *const HTDYORDERbegin = @"HTDYORDERsharebegin.data";
static NSString *const HTDYORDERend = @"HTDYORDERend.data";
static NSString *const HTDYORDERUid = @"HTDYORDERuid.data";
static NSString *const HTDYORDERintro = @"HTDYORDERintro.data";
static NSString *const HTDYORDERnickname = @"HTDYORDERsharenickname.data";
static NSString *const HTDYORDERPhone = @"HTDYORDERshareuserphone.data";


@implementation BookShareUserInforDefault

//读取登录状态
+ (BOOL)readLoginStatus{

    id status = [kUserDefaults objectForKey:HTDYORDERLoginStatus];
    return [status boolValue];
}

+ (void)saveLoginStatus:(BOOL)status
{
    [kUserDefaults setBool:status forKey:HTDYORDERLoginStatus];
    [kUserDefaults synchronize];
}
///** logintype */
//+ (void)saveUserLogintype:(NSString *)logintype{
//    [self saveWith:logintype tip:BOOKLogintype];
//}
//+ (NSString *)readLogintype{
//    return [self readWithTip:BOOKLogintype];
//}
/** account */
//+ (void)saveUserAccount:(NSString *)account{
//    [self saveWith:account tip:BOOKAccount];
//}
//
//+ (NSString *)readUserAccount{
//    return [self readWithTip:BOOKAccount];
//}
/** 用户头像地址 */
+ (void)saveUserAvatarUrl:(NSString *)avatarUrl{
   
    [self saveWith:avatarUrl tip:HTDYORDERUseravatarUrl];
}

+ (NSString *)readUserAvatarUrl{
    return [self readWithTip:HTDYORDERUseravatarUrl];
}
/** iscanOpenSecondUser 是否可开二级账户 */
+ (void)saveiscanOpenSecondUser:(NSString *)iscanOpenSecondUser{
    [self saveWith:iscanOpenSecondUser tip:HTDYIscanopensecondUser];
}

+ (NSString *)readiscanOpenSecondUser{
    return [self readWithTip:HTDYIscanopensecondUser];
}
/** address*/
+ (void)saveUserAddress:(NSString *)address{
     [self saveWith:address tip:HTDYORDERaddress];
}
+ (NSString *)readUserAddress{
    return [self readWithTip:HTDYORDERaddress];
}

/** begin */
+ (void)saveUserBegin:(NSString *)begin{
    [self saveWith:begin tip:HTDYORDERbegin];
}
+ (NSString *)readUserBegin{
     return [self readWithTip:HTDYORDERbegin];
}

/** end */
+ (void)saveUserEnd:(NSString *)end{
    [self saveWith:end tip:HTDYORDERend];
}
+ (NSString *)readEnd{
    return [self readWithTip:HTDYORDERend];
}

/** uid */
+ (void)saveUserUid:(NSString *)uid{
    [self saveWith:uid tip:HTDYORDERUid];
}
+ (NSString *)readUserUid{
    return [self readWithTip:HTDYORDERUid];
}

/** intro */
+ (void)saveUserIntro:(NSString *)intro{
    [self saveWith:intro tip:HTDYORDERintro];
}
+ (NSString *)readUserIntro{
    return [self readWithTip:HTDYORDERintro];
}

/** nickname */
+ (void)saveUserNicknames:(NSString *)nicknames{
    [self saveWith:nicknames tip:HTDYORDERnickname];
}
+ (NSString *)readNicknames{
    return [self readWithTip:HTDYORDERnickname];
}

/** phone */
+ (void)saveUserPhone:(NSString *)phone{
    [self saveWith:phone tip:HTDYORDERPhone];
}
+ (NSString *)readUserPhone{
    return [self readWithTip:HTDYORDERPhone];
}

+ (void)clearUserInfoNil{
    [self saveLoginStatus:NO];
    [self saveUserAvatarUrl:nil];
    [self saveUserAddress:nil];
    [self saveUserUid:nil];
    [self saveUserBegin:nil];
    [self saveUserEnd:nil];
    [self saveUserIntro:nil];
    [self saveUserNicknames:nil];
    [self saveUserPhone:nil];
}

+(void)saveWith:(NSString *)str tip:(NSString *)tip{
    [kUserDefaults setObject:str forKey:tip];
    [kUserDefaults synchronize];
}

+(NSString *)readWithTip:(NSString *)tip{
    return [kUserDefaults stringForKey:tip];
}

@end
